﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace LGSVR.Common
{
    public class OpLogBLL
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="loginType"></param>
        /// <param name="operatorStr">动作</param>
        /// <param name="opType"></param>
        /// <param name="opTime"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        public static int SaveLog(string userID, LogLoginType loginType, string operatorStr, LogOpType opType, DateTime opTime, string content)
        {
            List<SqlParameter> lstParam = new List<SqlParameter>();
            lstParam.Add(new SqlParameter("@userID", userID));  
            lstParam.Add(new SqlParameter("@opType", (int)opType));
            lstParam.Add(new SqlParameter("@opTime", opTime));

            SqlParameter parm2 = new SqlParameter("@operator", SqlDbType.VarChar, 128);
            parm2.Value = operatorStr;
            lstParam.Add(parm2);

            SqlParameter parm5 = new SqlParameter("@Content", SqlDbType.VarChar, 256);
            parm5.Value = content;
            lstParam.Add(parm5);
            lstParam.Add(new SqlParameter("@LoginType", loginType.ToString()));
           

            string str = "insert into opLog(userID,operator,opType,opTime,Content,LoginType)"
                       + " values(@userID,@operator,@opType,@opTime,@Content,@LoginType)";
            return LGSVR.Common.SQLHelper.ExecuteNonQuery(str, CommandType.Text, lstParam.ToArray());
        }
    }
    public enum LogLoginType
    {
        //网址
        W,
        //cs
        C,
        //手机端
        M
    }
    public enum LogOpType
    {
        程序异常日志,
        新增日志,
        修改日志,
        停用日志,
        删除日志        
    }
}
